'use strict';

module.exports = options => {
  return async function adminauth(ctx, next) {
    console.log('midd', ctx.session.openId, 'ctx.headers', ctx.headers);
    // if (ctx.session.openId && ctx.session.openId.openId) {// TODO:加密出问题了,用不了cookie session??crypto.createCipher is deprecated
    if (ctx.headers && ctx.headers.openid) {
      await next();
    } else {
      ctx.body = { data: '没有登录', noSession: true };
    }
  };
};
